using System;
using System.Collections.Generic;

namespace OffsetPath
{
    public class ClassAl : OffsetProfilo2D
    {
        public ClassAl()
        {
        }

        public ClassAl(ClassAl A_0) : base(A_0)
        {
        }

        public ClassAl(OffsetProfilo2D A_0) : base(A_0)
        {
        }

        public void a(double A_0)
        {
            this.GetStartPoint(A_0, this.c());
        }

        public void a(PuntoDueD A_0)
        {
            base.e();
            base.GetListaLineaArco().Add(new ForseLineaClassA(A_0, A_0));
        }

        public bool a(ClassAb A_0, int A_1, int A_2)
        {
            ClassN classN = new ClassN();
            if (!classN.MathodA1(A_0, A_1, A_2))
            {
                return false;
            }
            ClassAm classAm = new ClassAm(0.0, 1.0);
            base.MethodA(classN);
            for (int i = 0; i < base.GetListaLineaArco().Count; i++)
            {
                ClasseBaseLineaArcoClassAf classAf = base.GetListaLineaArco()[i];
                bool flag = classAm.d() > 0;
                double num2 = classAf.g();
                ClassAm am2 = new ClassAm(num2, num2 * 3.0);
                ForseArco2ClassQ classQ = new ForseArco2ClassQ(classAf.h(), classAf.i(), am2.MethodA(), flag, !flag);
                if (!base.MethodB(classQ))
                {
                    base.GetListaLineaArco()[i] = classQ;
                    classQ.f(base.w()[i]);
                    base.z().d(base.w()[i]);
                }
            }
            return true;
        }

        public void a(ClassAl A_0, List<ClassD> A_1, ClassAg A_2)
        {
            List<PolygonalShape> list = new List<PolygonalShape>();
            base.MethodA(A_0, list, A_2);
            for (int i = 0; i < list.Count; i++)
            {
                A_1.Add(new ClassD(list[i]));
            }
        }

        public void a(double A_0, bool A_1, bool A_2)
        {
            if (base.GetListaLineaArco().Count != 0)
            {
                base.GetListaLineaArco().Add(new ForseArco2ClassQ(base.GetListaLineaArco()[base.GetListaLineaArco().Count - 1].i(), base.GetListaLineaArco()[0].h(), A_0, A_1, A_2));
                base.ab();
                base.y();
            }
        }

        public void a(PuntoDueD A_0, double A_1, bool A_2, bool A_3)
        {
            if (base.GetListaLineaArco().Count != 0)
            {
                ForseArco2ClassQ item = new ForseArco2ClassQ(base.GetListaLineaArco()[base.GetListaLineaArco().Count - 1].i(), A_0, A_1, A_2, A_3);
                if (((base.GetListaLineaArco().Count == 1) && (base.GetListaLineaArco()[0] is ForseLineaClassA)) && (base.GetListaLineaArco()[0].i() == base.GetListaLineaArco()[0].h()))
                {
                    base.GetListaLineaArco()[0] = item;
                }
                else
                {
                    base.GetListaLineaArco().Add(item);
                }
            }
        }

        public void b()
        {
            if (base.GetListaLineaArco().Count != 0)
            {
                base.GetListaLineaArco().Add(new ForseLineaClassA(base.GetListaLineaArco()[base.GetListaLineaArco().Count - 1].i(), base.GetListaLineaArco()[0].h()));
                base.ab();
                base.y();
            }
        }

        public void b(PuntoDueD A_0)
        {
            if (base.GetListaLineaArco().Count != 0)
            {
                ForseLineaClassA item = new ForseLineaClassA(base.GetListaLineaArco()[base.GetListaLineaArco().Count - 1].i(), A_0);
                if (((base.GetListaLineaArco().Count == 1) && (base.GetListaLineaArco()[0] is ForseLineaClassA)) && (base.GetListaLineaArco()[0].i() == base.GetListaLineaArco()[0].h()))
                {
                    base.GetListaLineaArco()[0] = item;
                }
                else
                {
                    base.GetListaLineaArco().Add(item);
                }
            }
        }

        public void b(ClassAl A_0, List<ClassD> A_1, ClassAg A_2)
        {
            List<PolygonalShape> list = new List<PolygonalShape>();
            base.MethodB(A_0, list, A_2);
            for (int i = 0; i < list.Count; i++)
            {
                A_1.Add(new ClassD(list[i]));
            }
        }

        public PuntoDueD c()
        {
            PuntoDueD puntoDueD = new PuntoDueD(0.0, 0.0);
            double num = 0.0;
            for (int i = 0; i < base.GetListaLineaArco().Count; i++)
            {
                PuntoDueD x2 = base.GetListaLineaArco()[i].h();
                PuntoDueD x3 = base.GetListaLineaArco()[i].i();
                puntoDueD.X += (x2.X + x3.X) * ((x2.X * x3.Y) - (x3.X * x2.Y));
                puntoDueD.Y += (x2.Y + x3.Y) * ((x2.X * x3.Y) - (x3.X * x2.Y));
                num += (x2.X * x3.Y) - (x3.X * x2.Y);
            }
            num /= 2.0;
            puntoDueD.X /= 6.0 * num;
            puntoDueD.Y /= 6.0 * num;
            List<double> list = new List<double>();
            double num3 = num;
            List<PuntoDueD> list2 = new List<PuntoDueD>();
            for (int j = 0; j < base.GetListaLineaArco().Count; j++)
            {
                if (base.GetListaLineaArco()[j] is ForseArco2ClassQ)
                {
                    ClassAn classAn = new ClassAn(base.GetListaLineaArco()[j] as ForseArco2ClassQ);
                    double item = classAn.q();
                    num3 += item;
                    list.Add(item);
                    list2.Add(classAn.l());
                }
            }
            puntoDueD.MethodA(num);
            for (int k = 0; k < list.Count; k++)
            {
                puntoDueD.X += list2[k].X * list[k];
                puntoDueD.Y += list2[k].Y * list[k];
            }
            puntoDueD.MethodA((double) (1.0 / num3));
            return puntoDueD;
        }

        public void c(ClassAl A_0, List<ClassD> A_1, ClassAg A_2)
        {
            List<PolygonalShape> list = new List<PolygonalShape>();
            base.MethodC(A_0, list, A_2);
            for (int i = 0; i < list.Count; i++)
            {
                A_1.Add(new ClassD(list[i]));
            }
        }

        public double d()
        {
            double num = 0.0;
            for (int i = 0; i < base.GetListaLineaArco().Count; i++)
            {
                PuntoDueD puntoDueD = base.c[i].h();
                PuntoDueD x2 = base.c[i].i();
                num += (puntoDueD.X * x2.Y) - (x2.X * puntoDueD.Y);
            }
            num /= 2.0;
            for (int j = 0; j < base.GetListaLineaArco().Count; j++)
            {
                if (base.c[j] is ForseArco2ClassQ)
                {
                    ForseArco2ClassQ classQ = base.c[j] as ForseArco2ClassQ;
                    ClassAn classAn = new ClassAn(classQ);
                    num += classAn.q();
                }
            }
            return Math.Abs(num);
        }

        ~ClassAl()
        {
        }
    }
}

